<?php
$f =$_REQUEST["f"];

$con = mysqli_connect("localhost","root", "", "cqhg");
	mysqli_set_charset($con,"utf8");

 if($f=="1"){
	$ho ="select * from scgy limit 4";
		$hod =mysqli_query($con, $ho);
		$hodt=mysqli_fetch_all($hod,MYSQLI_ASSOC);
		$str =json_encode($hodt);
		echo $str;
}	
if($f=="2"){
	$ft =$_REQUEST["ft"];
	if($ft=="a"){
		$ho ="select * from scgy limit 4";
		$hod =mysqli_query($con, $ho);
		$hodt=mysqli_fetch_all($hod,MYSQLI_ASSOC);
		$str =json_encode($hodt);
		echo $str;
	}else{
		$ho ="select * from scgy where type= '{$ft}' limit 4";
		$hod =mysqli_query($con, $ho);
		$hodt=mysqli_fetch_all($hod,MYSQLI_ASSOC);
		$str =json_encode($hodt);
		echo $str;
	}
	
}

if($f=="3"){
	$fval =$_REQUEST["fval"];
	$ho ="select * from scgy where name= '{$fval}'";
		$hod =mysqli_query($con, $ho);
		$hodt=mysqli_fetch_all($hod,MYSQLI_ASSOC);
		$str =json_encode($hodt);
		echo $str;
}	

if($f=="4"){
	$s =$_REQUEST["s"];
	$ho ="select * from scgy where id= '{$s}'";
		$hod =mysqli_query($con, $ho);
		$hodt=mysqli_fetch_all($hod,MYSQLI_ASSOC);
		$str =json_encode($hodt);
		echo $str;
}		
?>